
//继承

class a {
    name:string;
    constructor(theName: string) { this.name = theName; }
    methoda(arg:number = 1) {
        console.log(`${this.name} method is ${arg*100}`);
    }
}

class b extends a {//继承类a，并通过methodb调用a方法
    constructor(name: string) { super(name); }
    methodb(arg:number = 2) {
        console.log("run b.methodb()");
        super.methoda(arg);
    }
}

class c extends a {//继承类a，并通过methoda调用a方法
    constructor(name: string) { super(name); }
    methoda(arg:number =3) {
        console.log("run c.methodc()");
        super.methoda(arg);
    }
}


let newb = new b("bbb");
let newc: a = new c("ccc");//赋值给newc的类型为a类，返回相对应的属性和方法

newb.methodb();
newc.methoda(10);
console.log('----------------------------------------');

//interface接口

interface person{
    name?: string;
    age?: number;
  }
  
function intfatest(config:person={age:123}): {name: string; maxage: number} {//返回属性类型
    let person = {name: "lala", maxage: 10};
    if (config.name) {
      person.name = config.name;
    }
    if (config.age) {
      person.maxage = config.age;
    }
    return person;
}
let person = intfatest({name: "riguang"});
console.log(person);